//
//  GJWXPayManager.m
//  xmgjAppFront
//
//  Created by Zeki on 2020/7/18.
//  Copyright © 2020 guojutech. All rights reserved.
//

#import "GJWXPayManager.h"

@implementation GJWXPayManager

#pragma mark - LifeCycle
+(instancetype)sharedManager {
    static dispatch_once_t onceToken;
    static GJWXPayManager *instance;
    dispatch_once(&onceToken, ^{
        instance = [[GJWXPayManager alloc] init];
    });
    return instance;
}

#pragma mark - WXApiDelegate
- (void)onResp:(BaseResp *)resp {
    if([resp isKindOfClass:[PayResp class]]){
      PayResp *parSp = (PayResp *)resp;
      GJLog(@"result wxpay = %@",parSp.returnKey);
      NSMutableDictionary *dic = [NSMutableDictionary dictionary];
      //通知js支付结果
      switch (resp.errCode) {
          case WXSuccess:
        {
          //支付成功
           [dic setValue:@"1" forKey:@"status"];
        }break;
              
        default:{
          //支付失败
           [dic setValue:@"0" forKey:@"status"];
        }break;
      }
      
      //支付失败
      [[NSNotificationCenter defaultCenter] postNotificationName:GJKPayResultNotification object:nil userInfo:dic];
    }
}

- (void)onReq:(BaseReq *)req {

}
@end
